libxl: Protect fds with CLOEXEC even with forking threads
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 11 Apr 2012 13:14:18 +0000 (14:14 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Wed, 11 Apr 2012 13:14:18 +0000 (14:14 +0100)
commitda31ffa712dbbe9540a7b9c2b7bee4d3315c1cd1
treed9134fca3659e8a649f433d03f8aacc620101675
parent88d3e27049298a53d9f9f5c8600d2799dc88ef7b
libxl: Protect fds with CLOEXEC even with forking threads

We introduce a new "carefd" concept, which relates to fds that we care
about not being inherited by long-lived children.

As yet we do not use this anywhere in libxl.  Until all locations in
libxl which make such fds are converted, libxl__postfork may not work
entirely properly.  If these locations do not use O_CLOEXEC (or use
calls for which there is no O_CLOEXEC) then multithreaded programs may
not work properly.

This introduces a new API call libxl_postfork_child_noexec which must
be called by applications which make long-running non-execing
children.  Add the appropriate call to xl's postfork function.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/Makefile
tools/libxl/libxl.c
tools/libxl/libxl_event.h
tools/libxl/libxl_fork.c [new file with mode: 0644]
tools/libxl/libxl_internal.h
tools/libxl/xl.c